package com.ease.plugin
{
	import com.ease.plugin.utils.PluginStrings;
	
	
	/**
	 * Encapsulation of all information needed to dynamically create and
	 * initialize a MediaElement from a MediaFactory.
	 *  
	 *  @langversion 3.0
	 *  @playerversion Flash 10
	 *  @playerversion AIR 1.5
	 *  @productversion OSMF 1.0
	 */
	public class PluginFactoryItem
	{
		public function PluginFactoryItem
							( id:String
							, canHandleResourceFunction:Function
							, pluginElementCreationFunction:Function
							, type:String=null
							)
		{
			if (	id == null
			     || canHandleResourceFunction == null
			     || pluginElementCreationFunction == null
			   )
			{
				throw new ArgumentError(PluginStrings.getString(PluginStrings.INVALID_PARAM));
			}
			
			_id = id;
			_canHandleResourceFunction = canHandleResourceFunction;
			_pluginElementCreationFunction = pluginElementCreationFunction;
			_type = type;
		}
		
		public function get id():String
		{
			return _id;
		}
		
		/**
		 * Function which is used to determine whether this MediaFactoryItem can handle
		 * a particular resource.  The function must take a single parameter of
		 * type MediaResourceBase, and return a Boolean.
		 *  
		 *  @langversion 3.0
		 *  @playerversion Flash 10
		 *  @playerversion AIR 1.5
		 *  @productversion OSMF 1.0
		 */
		public function get canHandleResourceFunction():Function
		{
			return _canHandleResourceFunction;
		}

		/**
		 * Function which creates a new instance of the desired MediaElement.
		 * The function must take no params, and return a MediaElement.
		 *  
		 *  @langversion 3.0
		 *  @playerversion Flash 10
		 *  @playerversion AIR 1.5
		 *  @productversion OSMF 1.0
		 */
		public function get pluginElementCreationFunction():Function
		{
			return _pluginElementCreationFunction;
		}
		
		/**
		 * The MediaFactoryItemType for this MediaFactoryItem.
		 *  
		 *  @langversion 3.0
		 *  @playerversion Flash 10
		 *  @playerversion AIR 1.5
		 *  @productversion OSMF 1.0
		 */
		public function get type():String
		{
			return _type;
		}
		
		// Internals
		//
		
		private var _id:String;
		private var _canHandleResourceFunction:Function;
		private var _pluginElementCreationFunction:Function;
		private var _type:String;
	}
}